package com.shudaolink.wms.print.servive.impl;

import com.shudaolink.wms.print.servive.WmsPrintService;
import com.shudaolink.wms.print.util.PrintConnectionUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.springframework.stereotype.Service;

import java.awt.print.PrinterJob;
import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * @author : Sakura
 * @Date : 2024/4/16 10:17
 * @Description : TODO
 */
@Service
@Slf4j
public class PrintServiceImpl implements WmsPrintService {
    @Override
    public void commonPrint(String pdfPath, String printerName) throws Exception {
        File file = new File(pdfPath);
        PDDocument document = PDDocument.load(file);
        PrinterJob job = PrintConnectionUtil.getPrintServiceByName(printerName);
        log.info("开始打印,打印机:+" + printerName + ",打印地址:" + pdfPath);
        job.print();
        document.close();
    }
}
